home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
trace1a.arc
/
TRACE12.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-02-03
|
13KB
|
363 lines
page 60,132
title "TRACE - Interrupt Tracer"
;make sure this gets linked last
page
code segment para public 'code'
assume cs:code,ds:code,es:code
public trace_table,init
extrn trace_begin:word,trace_curr:word,trace_end:word,trace_bytes:word
extrn feed:near,crlf:near,print_hex:near,print_line:near
extrn disp_active:near,selvideo:near,periscope:near
extrn hndlr_index:word,ict_index:word,prt_base:word
extrn our_cs:word,test_cs:word
extrn prtsc:near
radix dw 10
one_k dw 1024
include trace1e.aic
trace_table db 0
asciitable db '0123456789ABCDEF' ;table of characters
asciibin proc near ;si - source of characters (left end)
;ax - contents in binary
;cx - length in bytes
push bx
xor ax,ax
xor bx,bx
asciiloop:
mov bl,[si] ;get character pointed to by SI
cmp bl,' ' ;is character a blank?
je asciiexit ;if so, that is it.
cmp bl,'0'
jl asciierror
mul radix ;multiply ax by radix
cmp bl,'9'
jg asciihex ;if character > 9 must be hex
and bl,0fh ;pick up numeric part
asciiadd: ;add to accumulator
add ax,bx
inc si ;scan right
loop asciiloop
jmp asciiexit
asciihex: cmp radix,10 ;radix >10?
jle asciierror ;if not, error
or bl,20h ;make lower case
cmp bl,'a'
jl asciierror
cmp bl,'f'
jg asciierror
sub bl,87 ;turn 'A' into 10, etc
jmp asciiadd
asciierror: ;error exit
xor ax,ax ;return a zero on error
stc ;set carry flag: error
jmp asciiret ;exit
asciiexit: ;non-error exit
clc
asciiret: ;general exit
pop bx
ret
asciibin endp
parmlen equ 80h
parmdata equ 81h
scan_parm proc near ;get next parm start in es:di
push ax
mov al,' ' ;put blank in accumulator
cmp cx,0 ;is there any parm left?
je scan_none ;if not, just exit
scan_loop: repz scasb ;get byte pointed to by es:di
je scan_none ;if all blank, no parm`
dec di ;back up over character
inc cx
clc ;set no carry
scan_ret:
pop ax ;restore register
ret
scan_none:
stc ;set carry
jmp scan_ret
scan_parm endp
;********************************************************
;
; Startup messages (lost once we're resident)
;
;********************************************************
copyright db cr,lf
db "TRACE - Interrupt Tracer version 1.21 01/26/87"
db cr,lf
db cr,lf
db "Written by Joan Riff for:"
db cr,lf
db "Computerwise Consulting Services P.O. Box 813, McLean VA 22101 (703) 280-2809"
db cr,lf
db "Modified 01/26/87 A. B. Krueger - ARNY KRUEGER @ EXEC-PC"
db cr,lf,"$"
default_msg db cr,lf
db "Using default sized trace table."
db cr,lf
db "Usage is: TRACE [parameter]"
db cr,lf
db "Optional parameter is size in K between 10 and 63"
db cr,lf,"$"
here_already db cr,lf
db "TRACE already installed, errorlevel = 10"
db cr,lf,"$"
intro_msg db cr,lf
db cr,lf
db "Trace is now resident."
db cr,lf
db "Use '/U 9' Periscope command"
if prt_scr
db " (or SHIFT-PrtSc)"
endif
db " for access."
db cr,lf
db "When you run Periscope, include command-line arg /I:$"
bad_exit db "has a bad Exit field. ICT deactivated.$"
two_prtscrs db "overlays SHIFT-PrtSc. ICT deactivated.$"
no_printer db cr,lf,"*** Warning: LPT1 not available$"
err_msg db cr,lf,"*** ICT #"
err_ict db "0 $"
final_msg db cr,lf
db cr,lf,"Final ICT's:",cr,lf,"$"
subttl Startup (init) code
page
;********************************************************
;
; Startup code, which installs us in memory and sets up interrupts
; to be handled.
;
;********************************************************
init:
mov bx,0 ;set up to see if i am already here
mov ax,iamhere
int 21h ;run the test
cmp bx,iamhere ;if AX and BX swapped, i am here already
jne init00
mov dx,offset here_already ;complaint department
mov ah,9
int 21h
mov al,10 ;error level = 10
mov ax,4ch
int 21h ;return to caller
init00:
mov ax,trace_size ;set default trace table size
mov di,parmdata
xor cx,cx
mov cl,cs:[parmlen]
call scan_parm ;call scan for start of parm
jc init01 ;if none, use default
mov si,di ;now loading, not scanning
call asciibin ;turn chars into binary in ax
jc init01 ;any errors? - use default
cmp ax,63 ;above 63K?
ja init01 ;then set default
cmp ax,9 ;too small?
ja init02 ;if not use it
init01:
mov dx,offset default_msg
mov ah,9
int 021h
mov ax,trace_size ;set default trace table size
init02:
mul one_k ;turn number into K-bytes
mov trace_bytes,ax
mov our_cs,cs ;save for handlers' use
mov test_cs,cs ;start normalized CS for testing
mov ax,offset init ;include all of resident part in it
mov cl,4
shr ax,cl
add test_cs,ax ;done normalizing it
mov dx,offset copyright
mov ah,9
int 021h
;
; Get printer base I/O address for use later
;
mov ax,040h ;point to parallel table at 0040:0008
mov es,ax
mov dx,es:[8] ;get LPT1's base address
mov prt_base,dx ;save it
or dx,dx ;is there an LPT1?
jnz init2 ;yes, move on
mov dx,offset no_printer ;no, give warning message...
call selvideo ;...after switching to video
call print_line
init2:
;
; Init proper I/O mode
;
if use_prt
call selprint
else
call selvideo
endif
;
; Install Periscope access interrupt # 'peri_int'
;
mov al,peri_int ;INT # being installed
mov ah,025h ;DOS "Install Int Vector" func
mov dx,offset periscope ;DS:DX = handler for this INT
int 021h
;
; Install SHIFT-PrtSc interrupt
;
if prt_scr
mov al,5 ;INT # being installed
mov ah,025h ;DOS "Install Int Vector" func
mov dx,offset PrtSc ;DS:DX = handler for this INT
int 021h
endif
;
; Install interrupt vectors for any active ICT's
;
mov cx,number_icts ;number of ICT's
xor si,si ;Start with ICT # 0
init5:
mov bx,ict_index[si] ;get pointer to an ICT
mov al,[bx].ICT_flags ;get flags to AL
test al,F_ACTIVE ;is this ICT active?
jz init10 ;no, move on to next one
; ------- Validate type of interrupt exit
and al,F_RET+F_RET2+F_IRET
cmp al,F_RET
jz init6 ;this one's legal
cmp al,F_RET2
jz init6 ;this one's legal
cmp al,F_IRET
jz init6 ;this one's legal
mov dx,offset bad_exit ;bad field, give error message
init5b:
;
; Print error message at DS:DX and mark ICT de-activated
;
push dx ;save error message text
mov ax,si ;get ICT # for error message
shr ax,1
and al,7 ;(just in case)
or al,'0' ;make into ASCII digit
mov err_ict,al ;move into error header
mov dx,offset err_msg ;print error header first
call print_line
pop dx ;recover error message itself
call print_line ;display it
xor [bx].ICT_flags,F_ACTIVE ;de-activate this ICT
jmp short init10 ;goto next ICT
init6:
mov al,[bx].ICT_intnum ;get int number to AL
if prt_scr
cmp al,5 ;trying to trace INT 5?
jnz init6b ;no, it's all right
mov dx,offset two_prtscrs ;yes, give error message
jmp init5b
init6b:
endif
mov ah,035h ;get current vector for this INT
push bx ;(save ICT pointer!!!)
int 021h
mov dx,bx ;put vector's offset somewhere safe
pop bx ;(restore ICT pointer!!!)
mov word ptr [bx].ICT_orig_hndlr,dx
mov word ptr [bx].ICT_orig_hndlr+2,es
mov dx,hndlr_index[si] ;DS:DX = new vector for this INT
mov ah,025h ;tell DOS to install it
int 021h ;(intnum still in AL)
mov dx,offset trace_table ;minimum end of program
mov trace_curr,dx ;reset current trace table entry
init10:
add si,2 ;up to next ICT
loop init5 ;till done all ICT's
;
; List final ICT's
;
mov dx,offset final_msg
call print_line
call disp_active ;display all active ICT's
call crlf
;
; Terminate and stay resident
;
mov dx,offset intro_msg ;give him intro message
call print_line
mov al,peri_int
call print_hex
call crlf
call feed ;extra CRLF's for printer
mov dx,offset trace_table ;minimum end of program
mov trace_begin,dx ;set trace table start
mov trace_curr,dx ;reset current trace table entry
add dx,trace_bytes ;add in length of trace table
mov trace_end,dx ;save offset of end of trace table
int 027h
code ends
end